﻿Imports Fu3DEngine
Imports DrawContour
Imports System.IO

Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary

Public Class dlgVtkRender


    Public Sub dlgVtkRender()


       

    End Sub


   

    Private Sub dlgVtkRender_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        '这一步要求去掉对应的窗口

        FuEngine.GetEngine.GetScene("terrainscene").ClearScene()



    End Sub

    Private Sub dlgVtkRender_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.TreeCtl1.InitCtl()
        '初始化对应的树形控件
        TreeCtl1.SetPropCtl(PropCtl1)



        If FuEngine.GetEngine.GetScene("terrainscene") IsNot Nothing Then

            FuEngine.GetEngine.GetScene("terrainscene").InitScene(renderWindowControl1)

            FuEngine.GetEngine.RestoreSceneToTree()



        Else

            FuEngine.GetEngine().InitEngine()
            Dim ts As New TerrainScene("terrainscene")
            ts.desc = "地形场景"
            ts.InitScene(renderWindowControl1)

            FuEngine.GetEngine().AddScene(ts)




        End If






        If bReady Then

            Me.ShowVtk(m_IsDem, m_demFile, m_Rect, m_Proj, m_Cons)

        End If




    End Sub



    Protected Sub AddSource(ByVal m_proj As CAermod.ProjSet, ByVal ti As TerrainInfo)



        '    Case "cpoint" '关心点


        Dim layerConcern As New Layer("concernpoint")
        layerConcern.desc = "关心点"
        layerConcern.AmbientColor = Color.Yellow

        FuEngine.GetEngine.GetScene("terrainscene").AddNode(layerConcern)

        For i As Integer = 0 To m_proj.TempAermod.Receptor.DiscCarts.Length - 1


            Dim x, y, r, h, hg As Double
            x = Me.GetXAbs(m_proj.TempAermod.Receptor.DiscCarts(i).Xcoord)
            y = Me.GetYAbs(m_proj.TempAermod.Receptor.DiscCarts(i).Xcoord)

            r = 1

            h = m_proj.TempAermod.Receptor.DiscCarts(i).Zelev

            hg = m_proj.TempAermod.Receptor.DiscCarts(i).Zflag



            'CPCylinder cp = new CPCylinder(ti, 412579, 137800, 50, 1000);
            Dim cp As New CPCylinder(ti, x, y, r, h, hg)
            Dim cpnode As New CylinderNode(cp, m_proj.TempAermod.Receptor.DiscCarts(i).ID)
            cpnode.desc = m_proj.TempAermod.Receptor.DiscCarts(i).Name

            layerConcern.Add(cpnode)

        Next



        ' Case "ppoint" 点源

        Dim layerPPoint As New Layer("pointsource")
        layerPPoint.AmbientColor = Color.Brown
        layerPPoint.desc = "点源"

        FuEngine.GetEngine.GetScene("terrainscene").AddNode(layerPPoint)



        For i As Integer = 0 To m_proj.TempAermod.Source.PointSources.PointSource.Length - 1


            Dim x, y, r, h As Double

            x = Me.GetXAbs(m_proj.TempAermod.Source.PointSources.PointSource(i).Location.Xs)
            y = Me.GetYAbs(m_proj.TempAermod.Source.PointSources.PointSource(i).Location.Ys)

            r = m_proj.TempAermod.Source.PointSources.PointSource(i).Stkdia / 2

            h = m_proj.TempAermod.Source.PointSources.PointSource(i).Stkhgt



            Dim cp As New CPCylinder(ti, x, y, r, h, 0)
            Dim cpnode As New CylinderNode(cp, m_proj.TempAermod.Source.PointSources.PointSource(i).Location.Srcid)
            cpnode.desc = m_proj.TempAermod.Source.PointSources.PointSource(i).SourceName

            layerPPoint.Add(cpnode)

        Next




        'Case "pline" '线源

        Dim layerLine As New Layer("linesource")

        layerLine.desc = "线源."
        layerLine.AmbientColor = Color.Coral
        FuEngine.GetEngine.GetScene("terrainscene").AddNode(layerLine)


        For i As Integer = 0 To m_proj.TempAermod.Source.LineSources.ArrayLineSources.Length - 1




            '声明一个数组啊

            Dim dps(m_proj.TempAermod.Source.LineSources.ArrayLineSources(i).LinePoints.Length - 1) As DPoint

            Dim x, y As Double

            For j As Integer = 0 To m_proj.TempAermod.Source.LineSources.ArrayLineSources(i).LinePoints.Length - 1

                x = Me.GetXAbs(m_proj.TempAermod.Source.LineSources.ArrayLineSources(i).LinePoints(j).x)

                y = Me.GetYAbs(m_proj.TempAermod.Source.LineSources.ArrayLineSources(i).LinePoints(j).y)



                '关于数组，哈哈
                Dim dp As New DPoint(x, y)

                dps(j) = dp


            Next

            Dim w As Double = m_proj.TempAermod.Source.LineSources.ArrayLineSources(i).Width

            Dim hg As Double = m_proj.TempAermod.Source.LineSources.ArrayLineSources(i).Height

            '半径，和高度，都没有定义哇

            Dim pl As New CPTubeLine(ti, w, 8, dps, hg)

            Dim tln As New TubeLineNode(pl, m_proj.TempAermod.Source.LineSources.ArrayLineSources(i).Location.Srcid)
            tln.desc = m_proj.TempAermod.Source.LineSources.ArrayLineSources(i).SourceName

            layerLine.Add(tln)






        Next



        'Case "poly" '多边形

        Dim layerPoly As New Layer("polysource")
        layerPoly.desc = "多边形源"


        layerPoly.AmbientColor = Color.Crimson



        FuEngine.GetEngine.GetScene("terrainscene").AddNode(layerPoly)


        For i As Integer = 0 To m_proj.TempAermod.Source.AreaPolySources.AreaPolySource.Length - 1




            Dim dps(m_proj.TempAermod.Source.AreaPolySources.AreaPolySource(i).GetVerts.Length - 1) As DPoint

            Dim x, y As Double

            For j As Integer = 0 To m_proj.TempAermod.Source.AreaPolySources.AreaPolySource(i).GetVerts.Length - 1

                x = Me.GetXAbs(m_proj.TempAermod.Source.AreaPolySources.AreaPolySource(i).GetVerts(j).X)

                y = Me.GetYAbs(m_proj.TempAermod.Source.AreaPolySources.AreaPolySource(i).GetVerts(j).Y)



                '关于数组，哈哈
                Dim dp As New DPoint(x, y)

                dps(j) = dp



            Next


            Dim hg As Double = m_proj.TempAermod.Source.AreaPolySources.AreaPolySource(i).Relhgt
            Dim hd As Double = m_proj.TempAermod.Source.AreaPolySources.AreaPolySource(i).Szinit
            If hd < 1 Then
                hd = 1
            End If


            Dim ply As New CPPoly(ti, hd, dps, hg)

            Dim plyNode As New PolygonNode(ply, m_proj.TempAermod.Source.AreaPolySources.AreaPolySource(i).Location.Srcid)
            plyNode.desc = m_proj.TempAermod.Source.AreaPolySources.AreaPolySource(i).SourceName

            layerPoly.Add(plyNode)


        Next

        'Case "cube" '体源

        Dim layerCube As New Layer("cubesource")
        layerCube.desc = "体源"
        layerCube.AmbientColor = Color.DarkRed


        FuEngine.GetEngine.GetScene("terrainscene").AddNode(layerCube)


        For i As Integer = 0 To m_proj.TempAermod.Source.VolumeSources.VolumeSource.Length - 1




            Dim ps As CAermod.VolumeSources

            ps = m_proj.TempAermod.Source.VolumeSources

            Dim x, y, dx, dy, dz As Double

            x = Me.GetXAbs(ps.VolumeSource(i).Location.Xs)
            y = Me.GetYAbs(ps.VolumeSource(i).Location.Ys)


            dx = ps.VolumeSource(i).Width
            dy = ps.VolumeSource(i).Width
            dz = ps.VolumeSource(i).Height

            If dz < 1 Then
                dz = 1
            End If

            Dim hg As Double = ps.VolumeSource(i).Relhgt


            Dim cube As New CPCube(ti, x, y, dx, dy, dz, hg)
            Dim cubeNode As New CubeNode(cube, m_proj.TempAermod.Source.VolumeSources.VolumeSource(i).Location.Srcid)
            cubeNode.desc = m_proj.TempAermod.Source.VolumeSources.VolumeSource(i).SourceName


            layerCube.Add(cubeNode)


        Next



        'Case "circle" '圆形面源

        Dim layerCircle As New Layer("circlesource")
        layerCircle.desc = "圆形面源"
        layerCircle.AmbientColor = Color.Aquamarine


        FuEngine.GetEngine.GetScene("terrainscene").AddNode(layerCircle)


        For i As Integer = 0 To m_proj.TempAermod.Source.AreacircSources.AreaCircSource.Length - 1


            Dim x, y, r, h
            x = Me.GetXAbs(m_proj.TempAermod.Source.AreacircSources.AreaCircSource(i).Location.Xs)
            y = Me.GetYAbs(m_proj.TempAermod.Source.AreacircSources.AreaCircSource(i).Location.Ys)

            r = m_proj.TempAermod.Source.AreacircSources.AreaCircSource(i).Radius

            h = m_proj.TempAermod.Source.AreacircSources.AreaCircSource(i).Szinit

            If h < 1 Then
                h = 1
            End If

            Dim hg As Double = m_proj.TempAermod.Source.AreacircSources.AreaCircSource(i).Relhgt '这里暂时理解面是没有高度的


            Dim cylinder As New CPCylinder(ti, x, y, r, h, hg)
            Dim cylinderNode As New CylinderNode(cylinder, m_proj.TempAermod.Source.AreacircSources.AreaCircSource(i).Location.Srcid)
            cylinderNode.desc = m_proj.TempAermod.Source.AreacircSources.AreaCircSource(i).SourceName

            layerCircle.Add(cylinderNode)

        Next




        'Case "rect" '矩形面源

        Dim layerRect As New Layer("rectsource")
        layerRect.desc = "矩形面源"
        layerRect.AmbientColor = Color.AliceBlue

        FuEngine.GetEngine.GetScene("terrainscene").AddNode(layerRect)


        For i As Integer = 0 To m_proj.TempAermod.Source.AreaSources.AreaSource.Length - 1



            ''设置第一个点
            'Dim ptA(3) As MapWinGIS.Point
            'ptA(0) = New MapWinGIS.Point
            'ptA(0).x = Me.GetUtmFromRelative(m_proj.TempAermod.Source.AreaSources.AreaSource(i).Location.Xs, m_proj.TempAermod.Source.AreaSources.AreaSource(i).Location.Ys).x
            'ptA(0).y = Me.GetUtmFromRelative(m_proj.TempAermod.Source.AreaSources.AreaSource(i).Location.Xs, m_proj.TempAermod.Source.AreaSources.AreaSource(i).Location.Ys).y
            ''设置第2个点
            'ptA(1) = New MapWinGIS.Point
            'ptA(1).y = ptA(0).y + m_proj.TempAermod.Source.AreaSources.AreaSource(i).Yinit * Math.Sin((90 - m_proj.TempAermod.Source.AreaSources.AreaSource(i).Angle) * Math.PI / 180)
            'ptA(1).x = ptA(0).x + m_proj.TempAermod.Source.AreaSources.AreaSource(i).Yinit * Math.Cos((90 - m_proj.TempAermod.Source.AreaSources.AreaSource(i).Angle) * Math.PI / 180)
            ''设置第4个点
            'ptA(3) = New MapWinGIS.Point
            'ptA(3).y = ptA(0).y + m_proj.TempAermod.Source.AreaSources.AreaSource(i).Xinit * Math.Sin(-m_proj.TempAermod.Source.AreaSources.AreaSource(i).Angle * Math.PI / 180)
            'ptA(3).x = ptA(0).x + m_proj.TempAermod.Source.AreaSources.AreaSource(i).Xinit * Math.Cos(-m_proj.TempAermod.Source.AreaSources.AreaSource(i).Angle * Math.PI / 180)

            ''设置第3个点
            'ptA(2) = New MapWinGIS.Point
            'ptA(2).y = (ptA(1).y - ptA(0).y) + ptA(3).y
            'ptA(2).x = (ptA(1).x - ptA(0).x) + ptA(3).x
            'fe.ptlist = ptA



            Dim dps(3) As DPoint

            dps(0) = New DPoint(Me.GetXAbs(m_proj.TempAermod.Source.AreaSources.AreaSource(i).Location.Xs), Me.GetYAbs(Me.GetXAbs(m_proj.TempAermod.Source.AreaSources.AreaSource(i).Location.Ys)))

            dps(1) = New DPoint()
            dps(1).x = dps(0).x + m_proj.TempAermod.Source.AreaSources.AreaSource(i).Yinit * Math.Cos((90 - m_proj.TempAermod.Source.AreaSources.AreaSource(i).Angle) * Math.PI / 180)
            dps(1).y = dps(0).y + m_proj.TempAermod.Source.AreaSources.AreaSource(i).Xinit * Math.Sin(-m_proj.TempAermod.Source.AreaSources.AreaSource(i).Angle * Math.PI / 180)


            dps(3) = New DPoint()
            dps(3).y = dps(0).y + m_proj.TempAermod.Source.AreaSources.AreaSource(i).Xinit * Math.Sin(-m_proj.TempAermod.Source.AreaSources.AreaSource(i).Angle * Math.PI / 180)
            dps(3).x = dps(0).x + m_proj.TempAermod.Source.AreaSources.AreaSource(i).Xinit * Math.Cos(-m_proj.TempAermod.Source.AreaSources.AreaSource(i).Angle * Math.PI / 180)


            dps(2) = New DPoint()
            dps(2).y = (dps(1).y - dps(0).y) + dps(3).y
            dps(2).x = (dps(1).x - dps(0).x) + dps(3).x






            Dim h As Double = m_proj.TempAermod.Source.AreaSources.AreaSource(i).Relhgt
            If h < 1 Then
                h = 1
            End If

            Dim hg As Double = m_proj.TempAermod.Source.AreaSources.AreaSource(i).Szinit

            Dim rect As New CPPoly(ti, h, dps, hg)
            Dim rectNode As New PolygonNode(rect, m_proj.TempAermod.Source.AreaSources.AreaSource(i).Location.Srcid)
            rectNode.desc = m_proj.TempAermod.Source.AreaSources.AreaSource(i).SourceName


            layerRect.Add(rectNode)


        Next




        'Case "exp" '敞口源

        Dim layerExp As New Layer("expsource")
        layerExp.desc = "敞口源"
        layerExp.AmbientColor = Color.DarkOrange

        FuEngine.GetEngine.GetScene("terrainscene").AddNode(layerExp)

        For i As Integer = 0 To m_proj.TempAermod.Source.OpenPitSources.OpenPitSource.Length - 1




            'fe.desc = m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).SourceName
            'fe.sn = m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Location.Srcid
            ''设置第一个点
            'Dim ptA(3) As MapWinGIS.Point
            'ptA(0) = New MapWinGIS.Point
            'ptA(0).x = Me.GetUtmFromRelative(m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Location.Xs, m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Location.Ys).x
            'ptA(0).y = Me.GetUtmFromRelative(m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Location.Xs, m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Location.Ys).y
            ''设置第2个点
            'ptA(1) = New MapWinGIS.Point
            'ptA(1).y = ptA(0).y + m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Yinit * Math.Sin((90 - m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Angle) * Math.PI / 180)
            'ptA(1).x = ptA(0).x + m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Yinit * Math.Cos((90 - m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Angle) * Math.PI / 180)
            ''设置第4个点
            'ptA(3) = New MapWinGIS.Point
            'ptA(3).y = ptA(0).y + m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Xinit * Math.Sin(-m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Angle * Math.PI / 180)
            'ptA(3).x = ptA(0).x + m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Xinit * Math.Cos(-m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Angle * Math.PI / 180)

            ''设置第3个点
            'ptA(2) = New MapWinGIS.Point
            'ptA(2).y = (ptA(1).y - ptA(0).y) + ptA(3).y
            'ptA(2).x = (ptA(1).x - ptA(0).x) + ptA(3).x



            Dim dps(3) As DPoint

            dps(0) = New DPoint(Me.GetXAbs(m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Location.Xs), Me.GetYAbs(m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Location.Ys))

            dps(1) = New DPoint()
            dps(1).x = dps(0).x + m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Yinit * Math.Cos((90 - m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Angle) * Math.PI / 180)
            dps(1).y = dps(0).y + m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Yinit * Math.Sin((90 - m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Angle) * Math.PI / 180)

            dps(3) = New DPoint()
            dps(3).y = dps(0).y + m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Xinit * Math.Sin(-m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Angle * Math.PI / 180)
            dps(3).x = dps(0).x + m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Xinit * Math.Cos(-m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Angle * Math.PI / 180)

            dps(2) = New DPoint()
            dps(2).y = (dps(1).y - dps(0).y) + dps(3).y
            dps(2).x = (dps(1).x - dps(0).x) + dps(3).x




            Dim hg As Double = m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Relhgt

            Dim h As Double = 1



            Dim rect As New CPPoly(ti, h, dps, hg)
            Dim rectNode As New PolygonNode(rect, m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).Location.Srcid)
            rectNode.desc = m_proj.TempAermod.Source.OpenPitSources.OpenPitSource(i).SourceName

            layerExp.Add(rectNode)




        Next


        'Case "build" '建筑物


        Dim layerBuild As New Layer("building")

        layerBuild.desc = "建筑物"
        layerBuild.AmbientColor = Color.BlanchedAlmond

        FuEngine.GetEngine.GetScene("terrainscene").AddNode(layerBuild)


        For i As Integer = 0 To m_proj.TempAermod.Bprm.ArryBldgi.Length - 1


            'fe.desc = m_proj.TempAermod.Bprm.ArryBldgi(i).BuildName
            'fe.sn = m_proj.TempAermod.Bprm.ArryBldgi(i).BuildStack
            ''设置第一个点
            'Dim ptA(m_proj.TempAermod.Bprm.ArryBldgi(i).ArryBuildTire(0).ArryBuilCorner.Length - 1) As MapWinGIS.Point
            'For j As Integer = 0 To m_proj.TempAermod.Bprm.ArryBldgi(i).ArryBuildTire(0).ArryBuilCorner.Length - 1
            '    ptA(j) = New MapWinGIS.Point
            '    ptA(j).x = Me.GetUtmFromRelative(m_proj.TempAermod.Bprm.ArryBldgi(i).ArryBuildTire(0).ArryBuilCorner(j).x, m_proj.TempAermod.Bprm.ArryBldgi(i).ArryBuildTire(0).ArryBuilCorner(j).y).x
            '    ptA(j).y = Me.GetUtmFromRelative(m_proj.TempAermod.Bprm.ArryBldgi(i).ArryBuildTire(0).ArryBuilCorner(j).x, m_proj.TempAermod.Bprm.ArryBldgi(i).ArryBuildTire(0).ArryBuilCorner(j).y).y

            'Next



            Dim dps(m_proj.TempAermod.Bprm.ArryBldgi(i).ArryBuildTire(0).ArryBuilCorner.Length - 1) As DPoint

            For j As Integer = 0 To m_proj.TempAermod.Bprm.ArryBldgi(i).ArryBuildTire(0).ArryBuilCorner.Length - 1

                Dim dp As New DPoint()

                dp.x = Me.GetXAbs(m_proj.TempAermod.Bprm.ArryBldgi(i).ArryBuildTire(0).ArryBuilCorner(j).x)
                dp.y = Me.GetYAbs(m_proj.TempAermod.Bprm.ArryBldgi(i).ArryBuildTire(0).ArryBuilCorner(j).y)

                dps(j) = dp

            Next

            Dim h As Double = m_proj.TempAermod.Bprm.ArryBldgi(i).ArryBuildTire(0).TireHight
            Dim hg As Double = 0

            Dim build As New CPPoly(ti, h, dps, hg)
            Dim buildNode As New PolygonNode(build, m_proj.TempAermod.Bprm.ArryBldgi(i).BuildStack)
            buildNode.desc = m_proj.TempAermod.Bprm.ArryBldgi(i).BuildName


            layerRect.Add(buildNode)


        Next








    End Sub


    Dim m_Ready As Boolean = False

    Dim xPre, yPre As Double


    Protected Function GetXAbs(ByVal x As Double) As Double

        Return x + xPre


    End Function

    Protected Function GetYAbs(ByVal y As Double) As Double

        Return y + yPre

    End Function


    Dim fPath As String = "c:\"



    '指示是否已经完全状态
    Dim bReady As Boolean = False

    '保存状态，便于调用
    Dim m_IsDem As Boolean
    Dim m_demFile As String
    Dim m_Rect As CAermod.RectArea
    Dim m_Proj As CAermod.ProjSet
    Dim m_Cons As DrawContour.Contours

    Public Sub InitVtk(ByVal isDem As Boolean, ByVal demFile As String, ByVal rect As CAermod.RectArea, ByVal proj As CAermod.ProjSet, ByVal cons As DrawContour.Contours)


        Me.m_IsDem = isDem
        Me.m_demFile = demFile
        Me.m_Rect = rect
        Me.m_Proj = proj
        Me.m_Cons = cons


        bReady = True


    End Sub


    Protected Sub ShowVtk(ByVal isDem As Boolean, ByVal demFile As String, ByVal rect As CAermod.RectArea, ByVal proj As CAermod.ProjSet, ByVal cons As DrawContour.Contours)







        '判断方案是否 已经存在，如果不存在就创建，存在就加载
        ' Dim bExist As Boolean = False
        Dim nameProj As String = fPath + "vtk.fzh"



        '先计算偏移量
        Dim recept As CAermod.Receptor = proj.TempAermod.Receptor
        Dim xRel, yRel As Double
        xRel = recept.SubGridCart(0).Xinit
        yRel = recept.SubGridCart(0).Yinit

        '定义对应的绝对和便宜坐标
        Dim xAbs, yAbs As Double
        xAbs = AermodProject0.GetLeftButtomUtmXY().x
        yAbs = AermodProject0.GetLeftButtomUtmXY().y


        xPre = xAbs - xRel
        yPre = yAbs - yRel




        '这里已经成功的求出了偏移量


        '然后分别算出主网格的对角坐标
        Dim enPtX, enPtY As Double
        enPtX = xAbs + recept.SubGridCart(0).Xdelta * (recept.SubGridCart(0).Xnum - 1)
        enPtY = yAbs + recept.SubGridCart(0).Ydelta * (recept.SubGridCart(0).Ynum - 1)




        '靠，忘记边界是绝对还是相对的了，先按绝对算

        Dim tii As TerrainInitInfo

        If isDem Then

            tii = New TerrainInitInfo(demFile)

        Else

            tii = New TerrainInitInfo(rect.Xmin + xPre, rect.Ymin + yPre, rect.Xmax + xPre, rect.Ymax + yPre)

        End If




        Dim tn As New TerrainNode("dem")
        tn.desc = "地形"
        Dim ti As TerrainInfo

        ti = tn.InitTerrain(tii)


        '这里调用有意义的坐标，才能够起作用,这里是主网格的对角，绝对值坐标

        tn.SetTextureCoord(xAbs, yAbs, enPtX, enPtY)

        tn.MyContours = cons


        Fu3DEngine.FuEngine.GetEngine().GetScene("terrainscene").AddNode(tn)




        '开始添加对应的污染源




        Me.AddSource(proj, ti)






        Fu3DEngine.FuEngine.GetEngine().Run()









        '  Me.renderWindowControl1.RenderWindow.GetRenderers.GetFirstRenderer.ResetCamera()

        m_Ready = True


    End Sub






End Class